package com.das.cloudmetro.ssoserver.security.jwt;

import org.springframework.context.annotation.*;
import org.springframework.beans.factory.annotation.*;
import com.das.framework.common.extvo.*;
import org.springframework.util.*;
import com.das.framework.common.jwt.*;
import com.das.framework.common.exception.*;
import io.jsonwebtoken.*;

@Configuration
public class JwtTokenService
{
    @Autowired
    private UserAuthConfig userAuthConfig;
    
    public LoginInfo getInfoFromToken(final String token) throws Exception {
        try {
            Assert.notNull((Object)token, "401: User token is null!");
            return JWTHelper.getInfoFromToken(token, this.userAuthConfig.getPubKeyByte());
        }
        catch (ExpiredJwtException ex) {
            throw new NotAuthorizationException("User token expired!");
        }
        catch (SignatureException ex2) {
            throw new NotAuthorizationException("User token signature error!");
        }
        catch (IllegalArgumentException ex3) {
            throw new NotAuthorizationException("User token is null or empty!");
        }
    }
}
